Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart intents in local #2915

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class FlowText extends ContentFieldsBase {
const botVariable = keyPath.endsWith(ACCESS_TOKEN_VARIABLE_KEY)
? match
: getValueFromKeyPath(request, keyPath)
// TODO In local if change variable and render multiple times the value is always the last update
replacedText = replacedText.replace(
match,
this.isValidType(botVariable) ? botVariable : match
Expand Down
2 changes: 1 addition & 1 deletion packages/botonic-plugin-flow-builder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class BotonicPluginFlowBuilder implements Plugin {
private flow?: HtFlowBuilderData
private functions: Record<any, any>
private currentRequest: PluginPreRequest
private getAccessToken: (session: Session) => string
public getAccessToken: (session: Session) => string
public getLocale: (session: Session) => string
public trackEvent?: TrackEventFunction
public getKnowledgeBaseResponse?: KnowledgeBaseFunction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { FlowBuilderApi } from '../api'
import { HtSmartIntentNode } from '../content-fields/hubtype-fields/smart-intent'
import { getFlowBuilderPlugin } from '../helpers'
import { EventAction, trackEvent } from '../tracking'
import { SmartIntentResponse } from '../types'

Expand Down Expand Up @@ -66,11 +67,14 @@
private async getInference(
inferenceParams: SmartIntentsInferenceParams
): Promise<SmartIntentResponse> {
const pluginFlowBuilder = getFlowBuilderPlugin(this.currentRequest.plugins)
const token = pluginFlowBuilder.getAccessToken(this.currentRequest.session)

Check warning on line 71 in packages/botonic-plugin-flow-builder/src/user-input/smart-intent.ts

View check run for this annotation

Codecov / codecov/patch

packages/botonic-plugin-flow-builder/src/user-input/smart-intent.ts#L70-L71

Added lines #L70 - L71 were not covered by tests

return await axios({
method: 'POST',
url: `${process.env.HUBTYPE_API_URL}/external/v2/ai/smart_intents/inference/`,
headers: {
Authorization: `Bearer ${this.currentRequest.session._access_token}`,
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
data: inferenceParams,
Expand Down
Loading