Emailing user transcript of conversation

Hi,

I’m relatively new to Botpress. I want to record the conversation for a given session and email it out to the user (a local email variable is set once the user’s email is asked in the conversation flow) after the conversation is finished. To do this, I’m guessing I’ll need to utilise the ‘Testing’ module with scenarios and then integrate that conversation into a product like SendGrid but I’m not fully sure. Does anyone know the easiest and most clear-cut way to achieve this?

Matt

Hey @mattkolomyjec !

Sorry for the (very) late response.

To retrieve the complete conversation transcript, there’s an API route for that. See https://github.com/botpress/botpress/blob/master/modules/channel-web/src/backend/api.ts#L422

You could call this API route from within a Botpress action, and send the transcript as an email from your Botpress action (using axios).

Hope this helps!

Thanks @spgin!

Just implemented what was suggested above, and here are my contributions:

  1. Sample custom action calling API: https://botpress.io/docs/tutorials/external-api#create-an-action
  2. The URL that axios invokes: http://localhost:3000/api/v1/bots/{your-bot-id}/mod/channel-web/conversations/{userId}/${conversationId}/download/txt
  3. The userId and conversationtId can be sourced from {{event.target}} and {{event.threadId}} respectively

Hope it helps!

1 Like

Thanks a lot for this @ching, that is awesome! :+1:

hello
i am working on a similar task i want to download the transcript conversation by default using call api skill and then send it by using the send email skill so can i get some help with that
i have tried this url : http://localhost:3000/api/v1/bots/my bot id/mod/channel-web/conversations/{{event.target}}/{{event.threadId}}/download/txt.
and i have implemented it in this code :
async function action(bp: typeof sdk, event: sdk.IO.IncomingEvent, args: any, { user, temp, session } = event.state){
/** Your code starts below */

const axios = require(‘axios’)

/**

// We assign the response to the session variable so we can use it later
session.response = data

}

// Actions are async, so make sure to return a promise
return callApi()
/** Your code ends here */
}
but i am getting an error 404 not found so please i hope to get a reply and thank you in advance

Hello Team,

I am trying the same thing attempted above i.e. emailing the conversation.

I have tried the following code as mentioned in the post above. But it is not working, I get an error. Please let me know the mistake I am making.

If I create the same URL manually i.e. picking user Id and conversation ID and typing it in the browser, I can see the data i.e JSON file. But I am unable to access the same using the axios.get function. Is the URL creation a problem???

Thanks in advance.

Regards
Vishwa
//------------------------------------------------------------------

const axios = require(‘axios’)

/**

  • @title Modifled call of the Github API to fetch Botpress repositories
  • @author Botpress, Inc.
    */
    const callApiNew = async () => {
    // We call the API
    uId = event.target
    cId = event.threadId
    const { data } = await axios.get(‘http://localhost:3000/api/v1/bots/maria/mod/channel-web/conversations/{uId}/{cId}/download/txt’)
    // Please note that there is a dollar ($$) while using {uId} and {cId} while creating the URL. i.e.: {uId}, {cId}.
    // We assign the response to the session variable so we can use it later
    session.response = data
    }

// Actions are async, so make sure to return a promise
return callApiNew()

Hello

This can be done in a simple way by performing string manipulations of the URL in Javascript.

Thanks,
Vishwa