Skip to content

Commit

Permalink
fix: neeeded changes to make fb template work
Browse files Browse the repository at this point in the history
  • Loading branch information
vanbasten17 committed Jan 28, 2025
1 parent 303daee commit c152a20
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions packages/botonic-plugin-flow-builder/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ export class FlowBuilderApi {
const newApi = new FlowBuilderApi()

newApi.url = options.url
newApi.flowUrl = options.flowUrl
newApi.flow = options.flow ?? (await newApi.getFlow(options.accessToken))
newApi.request = options.request

if (process.env.NODE_ENV === ProcessEnvNodeEnvs.DEVELOPMENT) {
await newApi.updateSessionWithUserInfo(options.accessToken)
}

const updatedRequest = newApi.request
newApi.flowUrl = options.flowUrl.replace(
'{bot_id}',
updatedRequest.session.bot.id
)
newApi.flow = options.flow ?? (await newApi.getFlow(options.accessToken))
return newApi
}

Expand Down
5 changes: 3 additions & 2 deletions packages/botonic-plugin-flow-builder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
import { getNodeByUserInput } from './user-input'
import { SmartIntentsInferenceConfig } from './user-input/smart-intent'
import { inputHasTextData, resolveGetAccessToken } from './utils'

export default class BotonicPluginFlowBuilder implements Plugin {
public cmsApi: FlowBuilderApi
private flow?: HtFlowBuilderData
Expand Down Expand Up @@ -74,9 +75,9 @@ export default class BotonicPluginFlowBuilder implements Plugin {

resolveFlowUrl(request: PluginPreRequest): string {
if (request.session.is_test_integration) {
return `${this.apiUrl}/v1/bot_flows/${request.session.bot.id}/versions/${FlowBuilderJSONVersion.DRAFT}`
return `${this.apiUrl}/v1/bot_flows/{bot_id}/versions/${FlowBuilderJSONVersion.DRAFT}`
}
return `${this.apiUrl}/v1/bot_flows/${request.session.bot.id}/versions/${this.jsonVersion}`
return `${this.apiUrl}/v1/bot_flows/{bot_id}/versions/${this.jsonVersion}`
}

async pre(request: PluginPreRequest): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
export function useWebviewContents<T extends MapContentsType>({
apiUrl = FLOW_BUILDER_API_URL_PROD,
version = FlowBuilderJSONVersion.LATEST,
// @ts-ignore
orgId,
botId,
webviewId,
Expand Down Expand Up @@ -85,7 +86,7 @@ export function useWebviewContents<T extends MapContentsType>({

useEffect(() => {
const getResponseContents = async () => {
const url = `${apiUrl}/v1/bot_flows/${botId}/versions/${version}/webviews/${webviewId}`
const url = `${apiUrl}/v1/bot_flows/${botId}/versions/${version}/webviews/${webviewId}/`

Check warning on line 89 in packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts

View check run for this annotation

Codecov / codecov/patch

packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts#L89

Added line #L89 was not covered by tests
try {
const response = await axios.get<WebviewContentsResponse>(url)

Check warning on line 91 in packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts

View check run for this annotation

Codecov / codecov/patch

packages/botonic-plugin-flow-builder/src/webview/use-webview-contents.ts#L91

Added line #L91 was not covered by tests

Expand Down

0 comments on commit c152a20

Please sign in to comment.