对话框流从lis中选择

2024-09-30 02:26:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建一个聊天机器人,它模仿呼叫中的ivr。例如,当用户说嗨(欢迎意图)时,我会发送一条信息,比如请从下面选择一个选项。你知道吗

 1, 2, 3, 4, 5 (every option gives user a unique information)

然后我创建了一个后续的欢迎意图Default welcome intent select.number

在这种情况下,当用户键入2时,我会给他另一组选项。 从下面选择选项

a, b, c, d, e, f

例如,对于用户类型a,我需要在dialogflow上创建什么意图来进一步处理。你知道吗

我正在使用python脚本截取用户回复

从python脚本调用dialogflow。你知道吗

 reply, intent, parameter = fetch_reply(x, session_id)

 def fetch_reply(query, session_id):
    response = detect_intent_from_text(query, session_id)

    inetnt = response.intent.display_name

    # print(inetnt)

    # print('-----')
    value = 0.0
    try:
        if response.parameters['number']:
            value = response.parameters['number'][0]

    except ValueError:
        print('no value found')

    return response.fulfillment_text, inetnt, value

从这里我可以简单地使用if else,如果用户选择a,然后给他回复,但是dialogflow提供了什么我可以用来给用户输入的答案。你知道吗

也有一个选项,用户喜欢按0返回主菜单。 我怎么处理?你知道吗

如果你想让我提供任何其他信息,请让我知道。你知道吗


Tags: 用户信息idnumbervalueresponsesession选项
1条回答
网友
1楼 · 发布于 2024-09-30 02:26:10

一种可能的方法是为每个可能的选项{1,2,3..a,b,c}创建意图,并在每个回复之后将它们作为建议包含在中。例如,当用户说“嗨”时,你可以用1,2,3回答“你好”。。。作为可选择的建议。当用户选择1时,a,b,c。。。作为建议出现。下面是一些代码可以帮助您:

.
.
.
const {Card, Suggestion} = require('dialogflow-fulfillment');
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
    const agent = new WebhookClient({request, response });
    function welcome(agent){
    agent.add(`Hello!`);
    agent.add(new Suggestion(`1`));
    agent.add(new Suggestion(`2`));
    agent.add(new Suggestion(`3`));
    }
.
.
.

相关问题 更多 >

    热门问题