Chuyển tới nội dung chính

sendFollowUpMessage

sendFollowUpMessage là JS API dùng để gửi một tin nhắn người dùng vào phiên chat đang hoạt động của app.

Import

import apis from '@v-miniapp/ai/apis'

Tham số

Thuộc tínhKiểu dữ liệuBắt buộcMô tả
promptstringNội dung tin nhắn cần gửi
scrollToBottombooleanCuộn chat xuống cuối sau khi gửi (mặc định: true)
success() => voidCallback khi gửi thành công
fail(error) => voidCallback khi thất bại
complete() => voidCallback khi hoàn tất (dù thành công hay thất bại)

Giá trị trả về

  • void

Ví dụ

Callback

import apis from '@v-miniapp/ai/apis'

apis.sendFollowUpMessage({
prompt: 'Cho tôi xem thêm thông tin',
scrollToBottom: true,
success: () => {
console.log('Gửi thành công')
},
fail: (err) => {
console.error('Lỗi', err)
},
})

Async/Await

import { apisAsync } from '@v-miniapp/ai/apis'

try {
await apisAsync.sendFollowUpMessageAsync({
prompt: 'Cho tôi xem thêm thông tin',
})
console.log('Gửi thành công')
} catch (err) {
console.error('Lỗi', err)
}