【问题标题】:Amplify Vue Chatbot not setting upAmplify Vue Chatbot 未设置
【发布时间】:2020-03-27 15:34:32
【问题描述】:

我正在尝试在我的应用程序中使用 Amplify Chatbot 组件,但我不断收到:

聊天机器人 - 未提供聊天机器人。

我使用 Amplify CLI 添加交互,将正确的配置添加到 aws-exports.js 文件中。然后我将 Amplify.Configure 设置为使用导出文件。

但是当我尝试在我的应用中使用该组件时,我似乎无法让它运行。

App.vue

<template>
  <amplify-chatbot ></amplify-chatbot>
</template>

<script>
import { Interactions } from 'aws-amplify';

export default {
  name: 'App',
  components: {
    Interactions
  },
  data(){
    return {
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

AWS 出口

// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = {
    "aws_project_region": "eu-west-1",
    "aws_cognito_identity_pool_id": "eu-west-1:fbc545c0-ddac-410b-8f8d-4ba3cffadbb2",
    "aws_cognito_region": "eu-west-1",
    "oauth": {},
    "aws_bots": "enable",
    "aws_bots_config": [
        {
            "name": "ScheduleAppointment_dev",
            "alias": "$LATEST",
            "region": "eu-west-1"
        }
    ]
};


export default awsmobile;

main.js

import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import Amplify, * as AmplifyModules from 'aws-amplify'
import { AmplifyPlugin } from 'aws-amplify-vue'
import awsconfig from './aws-exports'
Amplify.configure(awsconfig)

Vue.use(AmplifyPlugin, AmplifyModules)

Vue.config.productionTip = false

new Vue({
  render: h => h(App),
}).$mount('#app')

【问题讨论】:

  • 我从未使用过 aws-amplify,所以这是在黑暗中拍摄,但我没有看到您在任何地方使用 awsmobile(我看到它已定义,但未在任何地方导入和使用) .
  • 嘿 AlaxMA,感谢您的评论,甚至另一双眼睛也有帮助。我有 main.js 导入 aws-exports 文件,我将它添加到上面,这样更清楚:)

标签: vue.js aws-amplify amazon-lex


【解决方案1】:

这是你的 app.vue 的修改版本,它可以工作:

<template>
  <amplify-chatbot v-bind:chatbotConfig="chatbotConfig"></amplify-chatbot>
</template>

<script>
import { Interactions } from 'aws-amplify';

export default {
  name: 'App',
  data: () => ({
   chatbotConfig:{
     bot: "addTheBotNameHere",
     clearComplete: true
    },
  }),
  mounted() {
   Interactions.onComplete("addTheBotNameHere", this.handleComplete);
},
  methods: {

    handleComplete(err,confirmation) {

      if(err) {
         alert("bot conversation failed");
         return;
      }

      return "Thank You";
    },
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-30
    • 2020-08-30
    • 2020-03-01
    • 2020-12-16
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多